//
// Created by xili on 2024/7/31 13:56.
// Go big or go home.
//
#include <iostream>
#include <algorithm>

using namespace std;

class Solution {
public:
    string convertToBase7(int num) {
        string ans;
        if (num == 0) {
            return "0";
        }
        int n = num < 0 ? -num : num;
        while (n > 0) {
            ans += to_string(n % 7);
            n = n / 7;
        }
        if (num < 0) {
            ans += "-";
        }
        reverse(ans.begin(), ans.end());
        return ans;
    }
};